import es
import gamethread

from wcs.libs.players import players
from wcs.libs.items import items

itemName = 'Necklace of Protection'
item = items.addItem(itemName)
item.setGroup("defense")
item.setCost(3000)
item.setDescription("You nullify all damage fro the next 5 seconds")
item.aliveToUse = True
item.setMaxCount(1)
        
def wcs_item_bought(event_var):
    """
    Executed when a player buys an item, if the item bought was this item then
    make it so the player is invulnerable for 5 seconds.
    """
    userid = event_var["userid"]
    player = players[userid]
    if event_var['item'] == itemName:
        player.god(10)
        text = ("#greenNecklace of Protection #default- #lightgreenYou will " +
                "nullify all damage received for the next 5 seconds.")
        es.tell(userid, "#multi", text)